/**
 * 
 */
package com.douyu.ocean.recom.platfrom.core.web.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.douyu.ocean.recom.platform.api.model.entiry.RecomPos;
import com.douyu.ocean.recom.platfrom.core.service.RecomPosService;
import com.douyu.ocean.recom.platfrom.core.web.utils.ControllerUtils;
import com.douyu.ocean.recom.platfrom.core.web.utils.ResultUtils;
import com.douyu.ocean.recom.platfrom.core.web.vo.ResultWrapper;

/**
 * @author leiruiqi
 *
 */

@RequestMapping("/recom_platform/recomPos")
@RestController
public class RecomPosController extends BaseController{

	@Resource
	private RecomPosService recomPosService;

	@RequestMapping("/create")
	public ResultWrapper<?> create(final RecomPos record) {
		return ControllerUtils.doHandler(new ControllerUtils.ActionHandler() {

			@Override
			public ResultWrapper<?> getResponse() throws Exception {

				recomPosService.save(record);
				return ResultUtils.asSuccess(record.getId());
			}

		}, "RecomPosController.create");
	}

	@RequestMapping("/queryAll")
	public ResultWrapper<?> queryAll() {

		return ControllerUtils.doHandler(new ControllerUtils.ActionHandler() {

			@Override
			public ResultWrapper<?> getResponse() throws Exception {

				List<RecomPos> list = recomPosService.queryAllByStatus(1);
				return ResultUtils.asSuccess(list);
			}

		}, "RecomPosController.queryAll");
	}
	
	@RequestMapping("/updateStatusById")
	public ResultWrapper<?> updateStatus(final Long id,final Integer status) {

		return ControllerUtils.doHandler(new ControllerUtils.ActionHandler() {

			@Override
			public ResultWrapper<?> getResponse() throws Exception {
				RecomPos record = new RecomPos();
				record.setId(id);
				record.setStatus(status);
				recomPosService.updateById(record);
				return ResultUtils.asSuccess();
			}

		}, "RecomPosController.updateStatusById");
	}
	
}
